package com.czl.elm.controller;

import com.czl.elm.service.ISearchService;
import com.czl.elm.service.impl.SearchServiceImpl;
import com.czl.elm.util.ActionResult;
import io.swagger.annotations.ApiOperation;
import lombok.experimental.Accessors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.swing.*;
import java.util.List;

@RestController
@RequestMapping("/search")
public class SearchController {
    @Autowired
    private ISearchService searchService;

    @ApiOperation(value = "查询历史")
    @GetMapping("/shop")
    public ActionResult searchShopHistory(){

        List<String> res=searchService.searchShopHistory();
        if(res==null){
            return ActionResult.error("获取失败");
        }
        return ActionResult.success("获取成功",res);


    }

    @ApiOperation(value = "添加查询历史")
    @GetMapping("/addsearchshop")
    public ActionResult insertShopHistory(@RequestParam(value = "req") String req){

        searchService.insertShopHistory(req);

        return ActionResult.success("操作成功");
    }
    @ApiOperation(value = "删除查询历史")
    @GetMapping("/delsearchshop")
    public ActionResult delShopHistory(){

        searchService.delShopHistory();

        return ActionResult.success("操作成功");
    }

}
